package com.gitee.wsl.platform.network.command


import com.gitee.wsl.concurrent.executor.Executor
import kotlinx.coroutines.Runnable

interface ICommandClient<ClientConfig> : AutoCloseable {
    val clientConfig: ClientConfig

    fun newCommand(cmd: Short, flags: Short, data: String): BinaryCommand /*{
        return BinaryCommand.newCommand(this.clientConfig, cmd, flags, data)
    }
*/
    fun setOnChannelOpen(onOpen: Runnable)

    fun setOnChannelClose(onClose: Runnable)

    fun connect()

    fun send(cmd: BinaryCommand?, flush: Boolean)

    fun ping()

    fun reconnect()

    /**
     * recv函数只能由一个线程调用
     *
     * @param handler
     */
    fun recv(executor: Executor, handler: Consumer<BinaryCommand>)
}
